home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmigaPlus / AmigaOS / Aplus_Dev / AP-Website / links / include / update.php < prev   
Encoding:
PHP Script  |  2002-10-28  |  10.1 KB  |  427 lines

  1. <?
  2. // *******************************************************************
  3. //  include/update.php
  4. // *******************************************************************
  5.  
  6. unset($html);
  7.  
  8. $htmlsrc = $table2 . "<tr><td class=\"whatText\">Update Site Listing: ";
  9. $htmlsrc .= "</td></tr></table>";
  10.  
  11. echo whattable("100%","center","",$htmlsrc);
  12. unset($htmlsrc);
  13.  
  14. if(
  15.     !session_is_registered("LinkID") && 
  16.     !isset($validate_login) && 
  17.     !isset($finished_update)
  18. ){
  19.  
  20.     $html = $table . "<tr>";
  21.     $html .= "\r\n\t<td class=\"regularText\">" . $update_1 . " " . $update_2;
  22.     $html .= "<a class=\"regularText\" href=\"index.php?" . session_name() . "=";
  23.     $html .= session_id() . "&show=lost&ID=";
  24.     $html .= $ID . "\">" . $update_3 . "</a>" . $update_4 . "</td>\r\n</tr>\r\n";
  25.     $html .= "</table>\r\n";
  26. }
  27.  
  28. if(isset($html)){
  29.     
  30.     $final_html = table("100%","center","",$html);
  31.     unset($html);
  32. }
  33.  
  34. if(
  35.     
  36.     isset($validate_login) && 
  37.     !session_is_registered("LinkID")
  38. ){
  39.  
  40.     $sql = sql_query("
  41.         select
  42.             *
  43.         from
  44.             $tb_links
  45.         where
  46.             ID='$ID'
  47.         and
  48.             UserName = '$UserName'
  49.         and
  50.             Password = password('$Password')
  51.     ");
  52.  
  53.     if(sql_num_rows($sql) > 0){
  54.  
  55.         $rows = sql_fetch_array($sql);
  56.         $LinkID = $rows[ID];
  57.         session_register("LinkID");
  58.  
  59.     } else {
  60.  
  61.         $validate_login_error = 1;
  62.  
  63.         $html = "<br />" . $table . "<tr><td class=\"regularText\">" . $update_6 . "<br />";
  64.         $html .= "<a class=\"regularText\" href=\"index.php?" . session_name();
  65.         $html .= "=" . session_id() . "&show=lost&ID=";
  66.         $html .= $ID . "\">" . $update_3 . "</a>" . $update_4 . "</td></tr></table>";
  67.  
  68.     }
  69. }
  70.  
  71. if(isset($html)){
  72.     $final_html .= table("100%","center","",$html);
  73.     unset($html);
  74. }
  75.  
  76. if(isset($update_link)){
  77.     
  78.     $get_specs = sql_query("
  79.         select
  80.             *
  81.         from
  82.             $tb_specs
  83.         where
  84.             ID='1'
  85.     ");
  86.  
  87.     $spec = sql_fetch_array($get_specs);
  88.  
  89.     unset($error);
  90.  
  91.     if(strlen($SiteName) > $spec[SiteNameMax]){
  92.         
  93.         $error = 1;
  94.         $site_name_error = 1;
  95.     }
  96.  
  97.     if(strlen($SiteName) < $spec[SiteNameMin]){
  98.         
  99.         $error = 1;
  100.         $site_name_error = 1;
  101.     }
  102.  
  103.     if($SiteURL == "http://"){
  104.         
  105.         $SiteURL = "";
  106.     }
  107.  
  108.     if($url_validate == "Y"){
  109.  
  110.         if(!$get_url = @fopen($SiteURL,"r")){
  111.             
  112.             $error = 1;
  113.             $site_url_error = 1;
  114.         }
  115.     }
  116.  
  117.     if(strlen($Description) > $spec[DescMax]){
  118.         
  119.         $error = 1;
  120.         $description_error = 1;
  121.     }
  122.  
  123.     if(strlen($Description) < $spec[DescMin]){
  124.         
  125.         $error = 1;
  126.         $description_error = 1;
  127.     }
  128.  
  129.     if(strlen($Country) == 0){
  130.         
  131.         $error = 1;
  132.         $country_error = 1;
  133.     }
  134.  
  135.     if(strlen($UserName) < $spec[UserNameMin]){
  136.         
  137.         $error = 1;
  138.         $user_name_error = 1;
  139.     }
  140.  
  141.     if(strlen($UserName) > $spec[UserNameMax]){
  142.         
  143.         $error = 1;
  144.         $user_name_error = 1;
  145.     }
  146.  
  147.     if(strlen($Password) > 0){
  148.  
  149.         $update_pass = 1;
  150.  
  151.         if(strlen($Password) < $spec[PWMin]){
  152.             
  153.             $error = 1;
  154.             $password_error = 1;
  155.         }
  156.  
  157.         if(strlen($Password) > $spec[PWMax]){
  158.             
  159.             $error = 1;
  160.             $password_error = 1;
  161.         }
  162.  
  163.         if($Password != $Password2){
  164.             
  165.             $error = 1;
  166.             $password2_error = 1;
  167.         }
  168.  
  169.     }
  170.  
  171.     if(strlen($Hint) < $spec[HintMin]){
  172.         
  173.         $error = 1;
  174.         $hint_error = 1;
  175.     }
  176.  
  177.     if(strlen($Hint) > $spec[HintMax]){
  178.         
  179.         $error = 1;
  180.         $hint_error = 1;
  181.     }
  182.  
  183.     if(!ereg($spec[EmailSpec], $Email)){
  184.         
  185.         $error = 1;
  186.         $email_error = 1;
  187.     }
  188.  
  189.     if(!isset($error)){
  190.  
  191.         if($update_pass == 1){
  192.             
  193.             $sql = sql_query("
  194.                 update
  195.                     $tb_links
  196.                 set
  197.                     SiteName='$SiteName',
  198.                     SiteURL='$SiteURL',
  199.                     Description='$Description',
  200.                     Category='$Category',
  201.                     Country='$Country',
  202.                     Email='$Email',
  203.                     $Password=password('$Password'),
  204.                     Hint='$Hint'
  205.                 where
  206.                     ID='$ID'
  207.             ");
  208.  
  209.         } else {
  210.             
  211.             $sql = sql_query("
  212.                 update
  213.                     $tb_links
  214.                 set
  215.                     SiteName='$SiteName',
  216.                     SiteURL='$SiteURL',
  217.                     Description='$Description',
  218.                     Category='$Category',
  219.                     Country='$Country',
  220.                     Email='$Email',
  221.                     Hint='$Hint'
  222.                 where
  223.                     ID='$ID'
  224.             ");
  225.         }
  226.  
  227.         $html = "<br />" . $update_7 . "<a href=\"index.php?" . session_name();
  228.         $html .= "=" . session_id() . "&show=owner&ID=" . $ID;
  229.         $html .= "\">" . $update_40 . "</a>" . $update_8 . "<br />";
  230.  
  231.     } else {
  232.         
  233.         $html = "<br /><font class=\"errorTextBold\">" . $update_9 . "</font><br /><br />";
  234.     }
  235. }
  236.  
  237. if(isset($html)){
  238.  
  239.     $html_ = $table . "<tr><td class=\"regularText\" align=\"center\">";
  240.     $html_ .= $html . "</td></tr></table>";
  241.  
  242.     $final_html .= table("100%","center","",$html_);
  243.     
  244.     unset($html);
  245.     unset($html_);
  246. }
  247.  
  248. if(
  249.     (
  250.         session_is_registered("LinkID") && 
  251.         !isset($validate_login_error)
  252.     ) ||
  253.     isset($error)
  254. ){
  255.  
  256.     $sql = sql_query("
  257.         select
  258.             *
  259.         from
  260.             $tb_links
  261.         where
  262.             ID='$LinkID'
  263.     ");
  264.  
  265.     $rows = sql_fetch_array($sql);
  266.  
  267.     $html = "<br /><form method=\"post\" action=\"index.php?" . session_name() . "=";
  268.     $html .= session_id() . "&show=update&ID=" . $LinkID . "\"><input ";
  269.     $html .= "type=\"hidden\" name=\"finished_update\" value=\"1\" />";
  270.     $html .= $form_table . "<tr><td class=\"regularText\">" . $update_11;
  271.     $html .= "</td><td><input class=\"textBox\" type=\"text\" name=\"SiteName\"";
  272.     $html .= " size=\"35\" value=\"" . $rows[SiteName] . "\" />";
  273.  
  274.     if(isset($site_name_error)){
  275.         
  276.         $html .= "<br /><font class=\"errorText\">" . $update_12 . $update_13;
  277.         $html .= $spec[SiteNameMin] . $update_14 . $spec[SiteNameMax];
  278.         $html .= $update_15 . "</font>";
  279.     }
  280.     
  281.     $html .= "</td></tr><tr><td class=\"regularText\">" . $update_18 . "</td><td><input ";
  282.     $html .= "class=\"textBox\" type=\"text\" name=\"SiteURL\" size=\"35\" ";
  283.     $html .= "value=\"" . $rows[SiteURL] . "\" />";
  284.     
  285.     if(isset($site_url_error)){
  286.         
  287.         $html .= "<br /><font class=\"errorText\">" . $update_16 . "</font>";
  288.     }
  289.  
  290.     $html .= "</td></tr><tr><td class=\"regularText\">" . $update_19;
  291.     $html .= "</td><td><textarea class=\"textBox\" name=\"Description\" rows=\"7\" ";
  292.     $html .= "cols=\"45\">" . $rows[Description] . "</textarea>";
  293.  
  294.     if(isset($description_error)){
  295.         
  296.         $html .= "<br /><font class=\"errorText\">" . $update_17 . $update_13;
  297.         $html .= $spec[DescMin] . $update_14 . $spec[DescMax] . $update_15;
  298.         $html .= "</font>";
  299.     }
  300.     
  301.     $html .= "</td></tr><tr><td class=\"regularText\">" . $update_20 . "</td><td><select ";
  302.     $html .= "class=\"textBox\" name=\"Category\">";
  303.     
  304.     drop_cats($rows[Category], 0, "", $cats);
  305.     
  306.     $html .= $cats;
  307.     $html .= "</select></td></tr><tr><td class=\"regularText\">" . $update_21;
  308.     $html .= "</td><td><select class=\"textBox\" name=\"Country\">";
  309.             
  310.     if($d = dir("images/flags")){
  311.         
  312.         $html .= getFlagList("images/flags", $rows[Country]);
  313.     }
  314.             
  315.     $html .= "</select>";
  316.  
  317.     if(isset($country_error)){
  318.         
  319.         $html .= "<br /><font class=\"errorText\">" . $update_22 . "</font>";
  320.     }
  321.     
  322.     $html .= "</td></tr><tr><td class=\"regularText\">" . $update_23 . "</td><td><input ";
  323.     $html .= "class=\"textBox\" type=\"text\" name=\"UserName\" size=\"16\" value=\"";
  324.     $html .= $rows[UserName] . "\" />";
  325.     
  326.     if(isset($user_name_error)){
  327.         
  328.         $html .= "<br /><font class=\"errorText\">" . $update_24 . $update_13;
  329.         $html .= $spec[UserNameMin] . $update_14 . $spec[UserNameMax];
  330.         $html .= $update_15 . "</font>";
  331.     }
  332.     
  333.     $html .= "</td></tr><tr><td class=\"regularText\">" . $update_25 . "<br /><font ";
  334.     $html .= "size=\"-1\">" . $update_26 . "</font></td><td><input class=\"textBox\" ";
  335.     $html .= "type=\"password\" name=\"Password\" size=\"16\" value=\"";
  336.     
  337.     if(isset($Password) && !isset($validate_login)){
  338.         
  339.         $html .= $Password;
  340.     }
  341.     
  342.     $html .= "\" />";
  343.             
  344.     if(isset($password_error)){
  345.         
  346.         $html .= "<br /><font class=\"errorText\">" . $update_28;
  347.         $html .= $update_13 . $spec[PWMin] . $update_14 . $spec[PWMax];
  348.         $html .= $update_15 . "</font>";
  349.     }
  350.     
  351.     $html .= "</td></tr><tr><td class=\"regularText\">" . $update_29;
  352.     $html .= "</td><td><input class=\"textBox\" type=\"password\" ";
  353.     $html .= "name=\"Password2\" size=\"16\" value=\"";
  354.         
  355.     if(isset($Password2)){
  356.         $html .= $Password2;
  357.     }
  358.         
  359.     $html .= "\" />";
  360.  
  361.     if(isset($password2_error)){
  362.         
  363.         $html .= "<br /><font class=\"errorText\">" . $update_30 . "</font>";
  364.     }
  365.     
  366.     $html .= "</td></tr><tr><td class=\"regularText\">" . $update_31;
  367.     $html .= "</td><td><input class=\"textBox\" type=\"text\" name=\"Hint\" ";
  368.     $html .= "size=\"35\" value=\"" . $rows[Hint] . "\" />";
  369.             
  370.     if(isset($hint_error)){
  371.         
  372.         $html .= "<br /><font class=\"errorText\">" . $update_32;
  373.         $html .= $update_13 . $spec[HintMin] . $update_14 . $spec[HintMax];
  374.         $html .= $update_15 . "</font>";
  375.     }
  376.     
  377.     $html .= "</td></tr><tr><td class=\"regularText\">" . $update_39;
  378.     $html .= "</td><td><input class=\"textBox\" type=\"text\" name=\"Email\" ";
  379.     $html .= "size=\"35\" value=\"" . $rows[Email] . "\" />";
  380.  
  381.     if(isset($email_error)){
  382.         
  383.         $html .= "<br /><font class=\"errorText\">" . $update_33 . "</font>";
  384.     }
  385.  
  386.     $html .= "</td></tr><tr><td colspan=\"2\" align=\"center\"><input ";
  387.     $html .= "type=\"submit\" name=\"update_link\" value=\"" . $update_34;
  388.     $html .= "\" /></td></tr></table></form>";
  389. }
  390.  
  391. if(isset($html)){
  392.     
  393.     $final_html .= table("100%","center","",$html);
  394.     unset($html);
  395. }
  396.  
  397. if(
  398.     (
  399.         !session_is_registered("LinkID") || 
  400.         isset($validate_login_error)) && 
  401.         !isset($finished_update)
  402.     ){
  403.     
  404.     $html = "<br />" . $form_table . "<tr><form method=post action=\"index.php?";
  405.     $html .= session_name() . "=" . session_id() . "&show=update&ID=";
  406.     $html .= $ID . "\"><td class=\"regularText\" colspan=\"2\"><b>" . $update_35;
  407.     $html .= "</b></td></tr><tr><td class=\"regularText\">" . $update_36;
  408.     $html .= "</td><td><input class=\"textBox\" type=\"text\" name=\"UserName\" ";
  409.     $html .= "size=\"16\" value=\"" . $UserName . "\" maxlength=\"16\" /></td></tr>";
  410.     $html .= "<tr><td class=\"regularText\">" . $update_37 . "</td><td><input ";
  411.     $html .= "class=\"textBox\" type=\"password\" name=\"Password\" size=\"16\" ";
  412.     $html .= "value=\"" . $Password . "\" maxlength=\"16\" /></td></tr><tr><td ";
  413.     $html .= "colspan=\"2\" align=\"center\"><input type=\"submit\" ";
  414.     $html .= "name=\"validate_login\" value=\"" . $update_38 . "\" /></td>";
  415.     $html .= "</form></tr></table><br />";
  416. }
  417.  
  418. if(isset($html)){
  419.     
  420.     $final_html .= table("100%","center","",$html);
  421.     unset($html);
  422. }
  423.  
  424. echo $final_html;
  425.  
  426. ?>
  427.